<template lang="pug">
    div
      // el-button(type="primary" @click="tab") New tab 
      el-button(type="primary" @click="startDownload") 开始抓取
</template>
<script>
  export default {
    data: () => ({
    }),
    computed: { },
    created () { },
    mounted () { },
    methods: {
      tab () {
        chrome.tabs.create({ url: 'pages/app.html' })
      },
      startDownload () {
        let that = this
        that.queryHrefListLoading = true
        // chrome.runtime.sendMessage('changeColor')
        // chrome.runtime.sendMessage(chrome.runtime.id, 'get-download-links', (response) => {
        //   console.log(response)
        // })
        this.doInCurrentTab(function (tab) {
          console.log(tab)
          chrome.tabs.sendMessage(
            tab.id,
            'start-download',
            {},
            function (response) {
              console.log(response)
              that.downloadHrefList = response || []
              that.queryHrefListLoading = false
            }
          )
        })
      }
    }
  }
</script>
<style lang="scss">
  div {
    color: blue
  }
</style>